package com.wmccn.platform.util;

import java.io.InputStream;

import com.wmccn.platform.util.jdom.XMLProperties;


/**
 * @author zhangliang
 *
 * note:
 */
public class PropsUtil {

    public final static String module = PropsUtil.class.getName();

    public static String ENCODING = "UTF-8";

    private XMLProperties properties;

    private FileLocator fileLocator = new FileLocator();

    public PropsUtil(String configureFile) {
        loadProperties(configureFile);
    }

    public void loadProperties(String configName) {
        InputStream pathCongfgName = fileLocator.getConfStream(configName);
        if (pathCongfgName == null) {
            System.out.println(" cann't load config file:-->" + configName);
            return;
        }
        this.properties = new XMLProperties(pathCongfgName);
    }

    public String getProperty(String name) {
        String res = properties.getProperty(name);
        if (res == null)
            res = "";
        return res;
    }

    public String[] getChildrenProperties(String name) {
        return properties.getChildrenProperties(name);
    }

    public String[] getChildrenValues(String name) {
        return properties.getChildrenPropertiesValues(name);
    }

    public void setProperty(String name, String value) {
        properties.setProperty(name, value);
    }

}
